package com.flux.tms.tm${bean.numMain}srv.common.service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.powermock.api.mockito.PowerMockito;
import org.testng.annotations.BeforeClass;

import com.flux.wmsv5.comobjs.LoginInfoObj;
import com.flux.wmsv5.comobjs.ResultObj;
import com.flux.wmsv5.comobjs.RowDataException;
import com.flux.wmsv5.comservice.api.BsmConfigService;
import com.flux.wmsv5.comservice.api.IdSeqService;
import com.flux.wmsv5.comservice.api.StdBizExtExecuteService;
import com.flux.wmsv5.utils.RequestIdUtil;

public abstract class CommonService {
	@Mock
	protected StdBizExtExecuteService stdBizExtExecuteService;
	@Mock
	protected BsmConfigService bsmConfigService;
	@Mock
	protected IdSeqService idSeqService;

	protected ResultObj reObj = new ResultObj();
	protected ResultObj reObjErr = new ResultObj();
	protected LoginInfoObj loginInfoObj = new LoginInfoObj();
	protected Map<String,String> bizDataMap = new HashMap<String, String>();
	protected Map<String, Object> tmpMap = new HashMap<String, Object>();
	protected List<Map<String,Object>> dataList = new ArrayList<Map<String,Object>>();
	protected List<Map<String, Object>> tmpMapList = new ArrayList<Map<String,Object>>();
	protected RowDataException RowDataException = new RowDataException("A","mes");
     
	 @BeforeClass
	 public void beforeClass() {
		 CommonService commonService = returnSubClass();
		 MockitoAnnotations.initMocks(commonService);
		reObjErr.setCodeValueERR();
		<#--init();-->
	 }	
	 
	 /**
	  * 返回自己对象
	  * 
	  * <p>Author: ${bean.author}
	  * <p>Create Time:${bean.dayTime}
	  * 
	  * @return
	  */
	 protected abstract CommonService returnSubClass();
	 
	 /**
	  * 初始化登录对象
	  * 
	  * <p>Author: ${bean.author}
	  * <p>Create Time:${bean.dayTime}
	  *
	  */
	 protected void initLogin(){
		 loginInfoObj.setUserId("FANGXH");
		 loginInfoObj.setUserName("FANGXHDEBUGSQL");
		 loginInfoObj.setRemoteClientAddr("0.0.0.0");
		 loginInfoObj.setRequestId("ForTest");
		 loginInfoObj.setBizWarehouseId("TEST100");
		 loginInfoObj.setBizOrgId("FLUX");
		 loginInfoObj.setRequestId(RequestIdUtil.createId("A2002"));
		 initSubLogin();
	 }
	 
	 /**
	  * 子类初始化登录对象
	  * 
	  * <p>Author: ${bean.author}
	  * <p>Create Time:${bean.dayTime}
	  *
	  */
	 protected abstract void initSubLogin();
	 
	 /**
	  * 初始化业务数据信息
	  * 
	  * <p>Author: ${bean.author}
	  * <p>Create Time:${bean.dayTime}
	  *
	  */
	 protected void initBizDataMap(){
		 bizDataMap.put("organizationId", "FLUX");
		 bizDataMap.put("warehouseId", "TEST100");
		 initSubBizDataMap();
	 }
	 
	 /**
	  * 子类初始化业务数据信息
	  * 
	  * <p>Author: ${bean.author}
	  * <p>Create Time:${bean.dayTime}
	  *
	  */
	 protected abstract void initSubBizDataMap();

	<#--/**-->
	<#--* 对于一些公共的需要初始化-->
	<#--*-->
	<#--* <p>Author: fangxiaohai-->
	<#--* <p>Create Time: 2020年6月10日-->
	<#--*-->
	<#--* @throws Exception-->
	<#--*/-->
	<#--@SuppressWarnings("unchecked")-->
		<#--public void init() throws Exception{-->
		<#--reObj.setCodeValueOK();-->
		<#--PowerMockito.when(stdBizExtExecuteService.execute(any(LoginInfoObj.class),any(Map.class),any(String.class),any(String.class),any(String.class))).thenReturn(reObj);-->
		<#--PowerMockito.when(bsmConfigService.getMultiData(any(LoginInfoObj.class),any(Map.class))).thenReturn(reObj);-->
		<#--reObj.setPkey01("1111");-->
		<#--PowerMockito.when(idSeqService.getNextId(any(LoginInfoObj.class),any(Map.class))).thenReturn(reObj);-->
	<#--}-->
}
